﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ACH
{
    public partial class CreateLodgingRoom : Form
    {
        public CreateLodgingRoom()
        {
            InitializeComponent();
        }

        private void CreateLodgingRoom_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'aCHDataSet.TrainingTypes' table. You can move, or remove it, as needed.
            this.trainingTypesTableAdapter.Fill(this.aCHDataSet.TrainingTypes);
            // TODO: This line of code loads data into the 'aCHDataSet.RoomTypes' table. You can move, or remove it, as needed.
            this.roomTypesTableAdapter.Fill(this.aCHDataSet.RoomTypes);
            // TODO: This line of code loads data into the 'aCHDataSet.Lodgings' table. You can move, or remove it, as needed.
            this.lodgingsTableAdapter.Fill(this.aCHDataSet.Lodgings);

        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
            this.Close();
        }

        private void btnCreateLodgingRoom_Click(object sender, EventArgs e)
        {
            try
            {
                ACHDataSetTableAdapters.LodgingRoomsTableAdapter log = new ACHDataSetTableAdapters.LodgingRoomsTableAdapter();
                log.Insert(Guid.NewGuid().ToString(), txtDescription.Text, txtName.Text, 
                    (cmbLodgings.SelectedValue as DataRowView)["ID"].ToString(), (cmbRoomTypes.SelectedValue as DataRowView)["ID"].ToString(),
                    DateTime.Now, DateTime.Now, "PAUL", "PAUL");
                this.DialogResult = System.Windows.Forms.DialogResult.OK;
                this.Close();
            }
            catch (Exception ex) { MessageBox.Show(ex.Message); }
        }

        private void btnAddRoomType_Click(object sender, EventArgs e)
        {
            CreateRoomType rt = new CreateRoomType();
            rt.ShowDialog();
            //if (rt.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            //    cmbRoomTypes.Refresh();
        }
    }
}
